import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'

import NProgress from 'nprogress';
import 'nprogress/nprogress.css'
import { LoginPage, NotFound, RoomManagePage } from "@/views"
import { Layout } from "@/components"
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: "Login",
    component: LoginPage,
    meta: {
      usePathKey: true
    }
  }, {
    path: "/:pathMatch(.*)*",
    name: "Not Found",
    component: NotFound,
  }, {
    path: '/index',
    component: Layout,
    children: [
      {
        path:'roomManage',
        name: "RoomManage",
        component: RoomManagePage
      },
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

//  定义路由导航前置守卫
router.beforeEach((to, after, next) => {
  NProgress.start()
  next()
})
// eslint-disable-next-line
router.afterEach((to, from) => {
  NProgress.done()
})
//  定义路由导航后置守卫

export default router
